4 class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling {
6 func beginRequest(with context: NSExtensionContext) {
7 let request = context.inputItems.first as? NSExtensionItem
10 if #available(iOS 17.0, macOS 14.0, *) {
11 profile = request?.userInfo?[SFExtensionProfileKey] as? UUID
13 profile = request?.userInfo?["profile"] as? UUID
17 if #available(iOS 17.0, macOS 14.0, *) {
18 message = request?.userInfo?[SFExtensionMessageKey]
20 message = request?.userInfo?["message"]
23 os_log(.default, "Received message from browser.runtime.sendNativeMessage: %@ (profile: %@)", String(describing: message), profile?.uuidString ?? "none")
25 let response = NSExtensionItem()
26 response.userInfo = [ SFExtensionMessageKey: [ "echo": message ] ]
28 context.completeRequest(returningItems: [ response ], completionHandler: nil)